/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.ventas;

import Model.Cliente;
import Presenter.ClientePresenter;
import Presenter.EnvioPedidoPresenter;
import View.components.Index;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import Principals.Validadores;
import java.io.File;
import javax.swing.JFileChooser;

/**
 *
 * @author Paola
 */
public class Frm_RegistrarCliente extends javax.swing.JDesktopPane {

    Validadores val = new Validadores();

    /**
     * Creates new form Frm_RegistrarCliente
     */
    public Frm_RegistrarCliente() {
        initComponents();
        val.desactivarAccionPegar(txtNombres);
        val.desactivarAccionPegar(txtApPaterno);
        val.desactivarAccionPegar(txtApMaterno);
        val.desactivarAccionPegar(txtDocId);
        val.desactivarAccionPegar(txtDireccion);     
        val.desactivarAccionPegar(txtTelefono);
        val.desactivarAccionPegar(txtEmail);        
        EnvioPedidoPresenter.actualizarEnvioPedido() ; 
        btnCargarClienteMasiva.setEnabled(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        btnToolNuevo = new javax.swing.JButton();
        btnToolModificar = new javax.swing.JButton();
        btnToolGuardar = new javax.swing.JButton();
        btnToolEliminar = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        btnToolLimpiar = new javax.swing.JButton();
        btnToolBuscar = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnToolCancelar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        jtpCargaIndividual = new javax.swing.JTabbedPane();
        pnlRegistrarCliente = new javax.swing.JPanel();
        pnlRegistroCliente = new javax.swing.JPanel();
        lblNombres = new javax.swing.JLabel();
        lblApPaterno = new javax.swing.JLabel();
        lblApMaterno = new javax.swing.JLabel();
        txtNombres = new javax.swing.JTextField();
        txtApPaterno = new javax.swing.JTextField();
        txtApMaterno = new javax.swing.JTextField();
        lblDocId = new javax.swing.JLabel();
        txtDocId = new javax.swing.JTextField();
        pnlUbicacionCliente = new javax.swing.JPanel();
        lblDireccion = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        lblTelefono = new javax.swing.JLabel();
        lblEmail = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        pnlCargaMasiva = new javax.swing.JPanel();
        lblArchivo = new javax.swing.JLabel();
        txtNombreArchivo = new javax.swing.JTextField();
        btnExaminar = new javax.swing.JButton();
        btnCargarClienteMasiva = new javax.swing.JButton();
        barrita = new javax.swing.JProgressBar();

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setBorderPainted(false);

        btnToolNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Nuevo.png"))); // NOI18N
        btnToolNuevo.setEnabled(false);
        btnToolNuevo.setFocusable(false);
        btnToolNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolNuevoActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolNuevo);

        btnToolModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Editar.png"))); // NOI18N
        btnToolModificar.setEnabled(false);
        btnToolModificar.setFocusable(false);
        btnToolModificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolModificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolModificarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolModificar);

        btnToolGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Guardar.png"))); // NOI18N
        btnToolGuardar.setFocusable(false);
        btnToolGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolGuardarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolGuardar);

        btnToolEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Eliminar.png"))); // NOI18N
        btnToolEliminar.setEnabled(false);
        btnToolEliminar.setFocusable(false);
        btnToolEliminar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolEliminar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolEliminarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolEliminar);
        jToolBar1.add(jSeparator2);

        btnToolLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Limpiar.png"))); // NOI18N
        btnToolLimpiar.setFocusable(false);
        btnToolLimpiar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolLimpiar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolLimpiarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolLimpiar);

        btnToolBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Buscar.png"))); // NOI18N
        btnToolBuscar.setFocusable(false);
        btnToolBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolBuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolBuscarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolBuscar);
        jToolBar1.add(jSeparator1);

        btnToolCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Cancelar.png"))); // NOI18N
        btnToolCancelar.setFocusable(false);
        btnToolCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolCancelarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolCancelar);
        jToolBar1.add(jSeparator3);

        jtpCargaIndividual.setToolTipText("Carga Individual");

        pnlRegistrarCliente.setBorder(javax.swing.BorderFactory.createTitledBorder("Registro"));

        pnlRegistroCliente.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Personales"));

        lblNombres.setText("Nombres*:");
        lblNombres.setToolTipText("");

        lblApPaterno.setText("Apellido Paterno*:");

        lblApMaterno.setText("Apellido Materno*:");

        txtNombres.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombresKeyTyped(evt);
            }
        });

        txtApPaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApPaternoKeyTyped(evt);
            }
        });

        txtApMaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtApMaternoKeyTyped(evt);
            }
        });

        lblDocId.setText("Doc. Identidad*:");

        txtDocId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDocIdKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout pnlRegistroClienteLayout = new javax.swing.GroupLayout(pnlRegistroCliente);
        pnlRegistroCliente.setLayout(pnlRegistroClienteLayout);
        pnlRegistroClienteLayout.setHorizontalGroup(
            pnlRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlRegistroClienteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnlRegistroClienteLayout.createSequentialGroup()
                        .addComponent(lblApPaterno)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtApPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlRegistroClienteLayout.createSequentialGroup()
                        .addComponent(lblNombres)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(pnlRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblApMaterno)
                    .addComponent(lblDocId))
                .addGap(18, 18, 18)
                .addGroup(pnlRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtApMaterno, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                    .addComponent(txtDocId))
                .addContainerGap(107, Short.MAX_VALUE))
        );
        pnlRegistroClienteLayout.setVerticalGroup(
            pnlRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlRegistroClienteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblApMaterno)
                    .addComponent(txtApMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblApPaterno)
                    .addComponent(txtApPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlRegistroClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDocId)
                    .addComponent(txtDocId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombres)
                    .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pnlUbicacionCliente.setBorder(javax.swing.BorderFactory.createTitledBorder("Otros Datos"));

        lblDireccion.setText("Dirección*:");

        txtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDireccionKeyTyped(evt);
            }
        });

        lblTelefono.setText("Teléfono*:");

        lblEmail.setText("E-mail*:");

        txtTelefono.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtTelefonoKeyTyped(evt);
            }
        });

        txtEmail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtEmailKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout pnlUbicacionClienteLayout = new javax.swing.GroupLayout(pnlUbicacionCliente);
        pnlUbicacionCliente.setLayout(pnlUbicacionClienteLayout);
        pnlUbicacionClienteLayout.setHorizontalGroup(
            pnlUbicacionClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlUbicacionClienteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlUbicacionClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblDireccion)
                    .addComponent(lblTelefono)
                    .addComponent(lblEmail))
                .addGap(43, 43, 43)
                .addGroup(pnlUbicacionClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlUbicacionClienteLayout.createSequentialGroup()
                        .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(txtDireccion)
                    .addComponent(txtEmail))
                .addContainerGap())
        );
        pnlUbicacionClienteLayout.setVerticalGroup(
            pnlUbicacionClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlUbicacionClienteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlUbicacionClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblDireccion)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlUbicacionClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTelefono)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(pnlUbicacionClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEmail)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pnlRegistrarClienteLayout = new javax.swing.GroupLayout(pnlRegistrarCliente);
        pnlRegistrarCliente.setLayout(pnlRegistrarClienteLayout);
        pnlRegistrarClienteLayout.setHorizontalGroup(
            pnlRegistrarClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(pnlRegistroCliente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnlUbicacionCliente, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        pnlRegistrarClienteLayout.setVerticalGroup(
            pnlRegistrarClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlRegistrarClienteLayout.createSequentialGroup()
                .addComponent(pnlRegistroCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlUbicacionCliente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jtpCargaIndividual.addTab("Carga Individual", pnlRegistrarCliente);

        lblArchivo.setText("Archivo:");

        txtNombreArchivo.setEnabled(false);

        btnExaminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Examinar.png"))); // NOI18N
        btnExaminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExaminarActionPerformed(evt);
            }
        });

        btnCargarClienteMasiva.setText("Cargar");
        btnCargarClienteMasiva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCargarClienteMasivaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlCargaMasivaLayout = new javax.swing.GroupLayout(pnlCargaMasiva);
        pnlCargaMasiva.setLayout(pnlCargaMasivaLayout);
        pnlCargaMasivaLayout.setHorizontalGroup(
            pnlCargaMasivaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCargaMasivaLayout.createSequentialGroup()
                .addGroup(pnlCargaMasivaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlCargaMasivaLayout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addComponent(lblArchivo)
                        .addGap(18, 18, 18)
                        .addComponent(txtNombreArchivo, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnExaminar))
                    .addGroup(pnlCargaMasivaLayout.createSequentialGroup()
                        .addGap(259, 259, 259)
                        .addComponent(btnCargarClienteMasiva))
                    .addGroup(pnlCargaMasivaLayout.createSequentialGroup()
                        .addGap(211, 211, 211)
                        .addComponent(barrita, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(210, Short.MAX_VALUE))
        );
        pnlCargaMasivaLayout.setVerticalGroup(
            pnlCargaMasivaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlCargaMasivaLayout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(pnlCargaMasivaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnExaminar, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlCargaMasivaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(lblArchivo)
                        .addComponent(txtNombreArchivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(btnCargarClienteMasiva)
                .addGap(18, 18, 18)
                .addComponent(barrita, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(180, Short.MAX_VALUE))
        );

        jtpCargaIndividual.addTab("Carga Masiva", pnlCargaMasiva);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jtpCargaIndividual)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtpCargaIndividual, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29))
        );

        jtpCargaIndividual.getAccessibleContext().setAccessibleName("Carga Individual");
    }// </editor-fold>//GEN-END:initComponents

    private void cambiarVista(JDesktopPane panel) {
        ((Index) (this.getTopLevelAncestor())).changeDesktopPane(panel);
    }
    private void btnToolLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolLimpiarActionPerformed
        limpiar();
    }//GEN-LAST:event_btnToolLimpiarActionPerformed

    private void btnToolCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolCancelarActionPerformed
        cambiarVista(new Frm_BuscarCliente()); // si se cancela se va a buscar
    }//GEN-LAST:event_btnToolCancelarActionPerformed

    private void btnToolNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolNuevoActionPerformed
    }//GEN-LAST:event_btnToolNuevoActionPerformed

    private void btnToolModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolModificarActionPerformed
    }//GEN-LAST:event_btnToolModificarActionPerformed

    private void btnToolBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolBuscarActionPerformed
        cambiarVista(new Frm_BuscarCliente());
    }//GEN-LAST:event_btnToolBuscarActionPerformed

    private void btnToolEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolEliminarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnToolEliminarActionPerformed

    private void btnToolGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolGuardarActionPerformed
        try {
            String apPaterno = txtApPaterno.getText();
            String apMaterno = txtApMaterno.getText();
            String nombres = txtNombres.getText();
            String docId = txtDocId.getText();
            String direccion = txtDireccion.getText();
            String telefono = txtTelefono.getText();
            String email = txtEmail.getText();
            String msj_error = "";
            boolean error = false;

            if (apPaterno.isEmpty() || apMaterno.isEmpty() || nombres.isEmpty() || docId.isEmpty() || direccion.isEmpty() || telefono.isEmpty() || email.isEmpty()) {
                msj_error = "Debe ingresar todos los campos obligatorios.";
                error = true;
                //JOptionPane.showMessageDialog(this, "Por favor ingresar todos los campos");
            } //else {
            if (!apPaterno.isEmpty() && apPaterno.length() > 20) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("El campo Apellido Paterno debe ser máximo de 20 caracteres.");
                error = true;
            }            
            if (!apMaterno.isEmpty() && apMaterno.length() > 20) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("El campo Apellido Materno debe ser máximo de 20 caracteres.");
                error = true;
            }
            if (!nombres.isEmpty() && nombres.length() > 20) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("El campo Nombres debe ser máximo de 20 caracteres.");
                error = true;
            }            
            if (!docId.isEmpty() && docId.length() != 8) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("Debe ingresar un Documento de Identidad válido.");
                error = true;
            }
            if (!telefono.isEmpty() && telefono.length() < 7) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("Debe ingresar un Teléfono válido.");
                error = true;
            }
            if (!telefono.isEmpty() && telefono.length() > 10) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("Debe ingresar un Teléfono válido. (Tamaño máximo 10 dígitos)");
                error = true;
            }
            if (!email.isEmpty() && !val.validaEmail(email)) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("Debe ingresar un Email válido.");
                error = true;
                if (email.length()>40){
                   if (error) {
                    msj_error = msj_error.concat(" ");
                     }
                   msj_error = msj_error.concat("(Tamaño máximo 40 caracteres)");
                    error = true;
                }
            }
            

            if (error) {
                JOptionPane.showMessageDialog(this, msj_error);
            } else {
                int respuesta = JOptionPane.showConfirmDialog(this, "Está seguro de registrar al cliente", "Guardar", JOptionPane.OK_CANCEL_OPTION);
                switch (respuesta) {
                    case JOptionPane.OK_OPTION:
                        Cliente c = ClientePresenter.existeDocId(docId);
                        if (c != null) {
                            String msj = "El Documento de Identidad ya se encuentra registrado para el cliente:\n";
                            String cli = c.getNombres() + ' ' + c.getApellidoPaterno() + ' ' + c.getApellidoMaterno();
                            msj = msj.concat(cli);
                            JOptionPane.showMessageDialog(this, msj);
                            //JOptionPane.showMessageDialog(this, "El Documento de Identidad ya se encuentra registrado para el cliente: ");
                        } else {
                            ClientePresenter.registrarCliente(apPaterno, apMaterno, nombres, docId, direccion, telefono, email);
                            JOptionPane.showMessageDialog(this, "Se registró al cliente.");
                            limpiar();
                            cambiarVista(new Frm_BuscarCliente());
                        }
                        break;
                    case JOptionPane.CANCEL_OPTION:
                        break;
                }
                //cambiarVista(new Frm_BuscarCliente());
            }
            // }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(this, "No se pudo realizar la transacción.");
            System.out.println("MENSAJE DE ERROR:" + e);
        }
    }//GEN-LAST:event_btnToolGuardarActionPerformed

    private void txtApPaternoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApPaternoKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtApPaterno.getText());
        txtApPaterno.setTransferHandler(null);
    }//GEN-LAST:event_txtApPaternoKeyTyped

    private void txtApMaternoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApMaternoKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtApMaterno.getText());
        txtApMaterno.setTransferHandler(null);
    }//GEN-LAST:event_txtApMaternoKeyTyped

    private void txtNombresKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombresKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtNombres.getText());
        txtNombres.setTransferHandler(null);
    }//GEN-LAST:event_txtNombresKeyTyped

    private void txtDocIdKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDocIdKeyTyped
        val.validaSoloNumeros(evt);
        val.validaMaxSize(evt, 8, txtDocId.getText());
        txtDocId.setTransferHandler(null);
    }//GEN-LAST:event_txtDocIdKeyTyped

    private void txtDireccionKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDireccionKeyTyped
        val.validaCaracteresDirec(evt);
        val.validaMaxSize(evt, 40, txtDireccion.getText());
        txtDireccion.setTransferHandler(null);
    }//GEN-LAST:event_txtDireccionKeyTyped

    private void txtTelefonoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelefonoKeyTyped
        val.validaSoloNumeros(evt);
        val.validaMaxSize(evt, 10, txtTelefono.getText());
        txtTelefono.setTransferHandler(null);
    }//GEN-LAST:event_txtTelefonoKeyTyped

    private void txtEmailKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEmailKeyTyped
        val.validaCaracteresEmail(evt);
        val.validaMaxSize(evt, 40, txtEmail.getText());
        txtEmail.setTransferHandler(null);
    }//GEN-LAST:event_txtEmailKeyTyped

    private void btnCargarClienteMasivaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCargarClienteMasivaActionPerformed
        String path = txtNombreArchivo.getText();
        ClientePresenter.barrita = barrita ;
        ClientePresenter.registrarCliente(path);
        JOptionPane.showMessageDialog(this, "Se registraron los clientes con éxito");
        txtNombreArchivo.setText("");
        btnCargarClienteMasiva.setEnabled(false);
        cambiarVista(new Frm_BuscarCliente());
    }//GEN-LAST:event_btnCargarClienteMasivaActionPerformed

    private void btnExaminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExaminarActionPerformed
        JFileChooser fileChooser = new JFileChooser();

        int status = fileChooser.showOpenDialog(null);
        if (status == JFileChooser.APPROVE_OPTION) {
            File selectedFile = new File(fileChooser.getSelectedFile().getAbsolutePath());
            String path = selectedFile.getAbsolutePath();
            txtNombreArchivo.setText(path);
            btnCargarClienteMasiva.setEnabled(true);
        } else if (status == JFileChooser.CANCEL_OPTION) {
            System.out.println(JFileChooser.CANCEL_OPTION);
            btnCargarClienteMasiva.setEnabled(true);
        }
    }//GEN-LAST:event_btnExaminarActionPerformed

    private void limpiar() {
        txtApPaterno.setText("");
        txtApMaterno.setText("");
        txtNombres.setText("");
        txtDocId.setText("");
        txtDireccion.setText("");
        txtTelefono.setText("");
        txtEmail.setText("");
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JProgressBar barrita;
    private javax.swing.JButton btnCargarClienteMasiva;
    private javax.swing.JButton btnExaminar;
    private javax.swing.JButton btnToolBuscar;
    private javax.swing.JButton btnToolCancelar;
    private javax.swing.JButton btnToolEliminar;
    private javax.swing.JButton btnToolGuardar;
    private javax.swing.JButton btnToolLimpiar;
    private javax.swing.JButton btnToolModificar;
    private javax.swing.JButton btnToolNuevo;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JTabbedPane jtpCargaIndividual;
    private javax.swing.JLabel lblApMaterno;
    private javax.swing.JLabel lblApPaterno;
    private javax.swing.JLabel lblArchivo;
    private javax.swing.JLabel lblDireccion;
    private javax.swing.JLabel lblDocId;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblNombres;
    private javax.swing.JLabel lblTelefono;
    private javax.swing.JPanel pnlCargaMasiva;
    private javax.swing.JPanel pnlRegistrarCliente;
    private javax.swing.JPanel pnlRegistroCliente;
    private javax.swing.JPanel pnlUbicacionCliente;
    private javax.swing.JTextField txtApMaterno;
    private javax.swing.JTextField txtApPaterno;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtDocId;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtNombreArchivo;
    private javax.swing.JTextField txtNombres;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables
}
